package com.chenfan.process.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.ccp.common.result.R;
import com.chenfan.process.entity.dto.ProcessTransferDTO;
import com.chenfan.process.entity.po.ProcessTransferLogPo;
import com.chenfan.process.entity.po.TransferLogDetailPo;
import com.chenfan.process.service.ProcessTransferLogService;
import com.chenfan.process.service.TransferLogDetailService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author liuming
 * @date 2021/10/26
 */
@RequestMapping(value = "/approval/transfer/log")
@RestController
public class ApprovalTransferLogController {

    @Autowired
    private ProcessTransferLogService processTransferLogService;
    @Autowired
    private TransferLogDetailService transferLogDetailService;

    @ApiOperation("转移日志查询")
    @GetMapping(value = "")
    public R<Page<ProcessTransferLogPo>> page(ProcessTransferDTO processTransfer) {
        return R.data(processTransferLogService.pageLog(processTransfer));
    }

    /**
     * 转移日志详情查询
     * @param id 转移记录id
     * @param pageNum 页码
     * @param pageSize 页长
     * @return
     */
    @GetMapping("/{id}")
    public R<Page<TransferLogDetailPo>> pageTransferLog(@PathVariable Long id,
                                                        @RequestParam(value = "pageNun", defaultValue = "1") Integer pageNum,
                                                        @RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize) {
        return R.data(transferLogDetailService.pageTransferLog(id, pageNum, pageSize));
    }
}
